package cn.ynu.cmrs.activity;

import cn.ynu.cmrs.AppConstant;
import cn.ynu.cmrs.R;
import cn.ynu.cmrs.MyApplication;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

/**
 * Display 3 seconds animation when program starts
 * 
 * @author starsfury
 */
public class SplashscreenActivity extends Activity {
	
	private Animation startAnimation;
	private TextView version;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.splashscreen);
		MyApplication.IPConfig(this);
		Log.i("IP --- >", AppConstant.URL.BASE_URL);
		version = (TextView)findViewById(R.id.versionCode);
		version.setText(this.getString(R.string.version_code) + ":" + MyApplication.getInstance().getVersion());
		startAnimation = AnimationUtils.loadAnimation(this,
				android.R.anim.fade_in);
		startAnimation.setDuration(3 * 1000);
		startAnimation.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationEnd(Animation animation) {
				// TODO Auto-generated method stub
				LoginActivity.launch(SplashscreenActivity.this);
				finish();
			}

			@Override
			public void onAnimationRepeat(Animation animation) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onAnimationStart(Animation animation) {
				// TODO Auto-generated method stub

			}
		});
		findViewById(R.id.splashlayout).startAnimation(startAnimation);

	}

}
